//
//  GameDetailTableViewCell_Welfare.m
//  gamebox_qpp
//
//  Created by 赵隆杰 on 2022/9/3.
//

#import "GameDetailTableViewCell_Welfare.h"

@interface GameDetailTableViewCell_Welfare ()

@property (weak, nonatomic) IBOutlet UIView *bgView;
@property (weak, nonatomic) IBOutlet UILabel *cellText;

@end

@implementation GameDetailTableViewCell_Welfare

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)initCellData:(GameDetailNewModel *)detailModel
{
    self.cellText.text = detailModel.gameFuli;
    
    CALayer *layer = [self.bgView.layer.sublayers objectAtIndex:0];
    if ([layer isMemberOfClass:[CAGradientLayer class]]) {
        [layer removeFromSuperlayer];
    }
    CAGradientLayer *grad = [CAGradientLayer layer];
    grad.frame = self.bgView.bounds;
    grad.colors = [NSArray arrayWithObjects:(id)[UIColorHex(0xFEF5F3) CGColor], (id)[[UIColor whiteColor] CGColor], nil];
    [self.bgView.layer insertSublayer:grad atIndex:0];
}

+(CGFloat)height:(GameDetailNewModel *)detailModel
{
    CGFloat textHeight = 67;
    if (detailModel.isOpen_Fuli) {
        textHeight = [detailModel.gameFuli boundingRectWithSize:CGSizeMake(SL_WINDOW_WIDTH - 56, MAXFLOAT) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName: [UIFont systemFontOfSize:14]} context:nil].size.height+1;
    }
    
    return 10 + textHeight + 10;
}

@end
